package com.jblog.controller.directive.abs;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.jblog.common.web.freemarker.DirectiveUtils;
import com.jblog.core.service.facde.BlogFacade;

import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;

public abstract class AbstractArchiveDirective implements TemplateDirectiveModel{
    
    @Autowired protected BlogFacade iblog;
    
    public static final String PARAM_IS_POST_CALENDAR  = "isPostCalendar";

    protected Boolean isPostCalendar(Map<String, TemplateModel> params) throws TemplateException {
        return DirectiveUtils.getBool(PARAM_IS_POST_CALENDAR, params);
    }
    
    public Object getData(Map<String, TemplateModel> params,
            Environment env) throws TemplateException {
        
        if (null != isPostCalendar(params)) {
            return iblog.findCalendarArchiveOfPost();
        } else 
            return null;
    }
    
}
